<!--
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 14:41:20
 * @LastEditTime: 2023-10-05 12:59:24
 * @LastEditors: 孙开源 && sunkaiyuan@namenode.cn
 * @Description:   :gridOps="gridOptions" other
-->
<template>
  <sc-VxeTable
    ref="xGrid"
    :gridEvts="gridEvents"
    :tablecode="'qa_parameter_testing'"
    :url="api.pro.OpenCard.details"
    :children="{
      tablecode: 'qa_parameter_testing_sublist',
      url: api.pro.OpenCard.parameterTestingList,
      key: 'open_card_id',
    }"
  >
  </sc-VxeTable>

  <SaveDialog
    v-if="dialog.save"
    ref="saveDialog"
    @success="handleSuccess"
    @closed="dialog.save = false"
  ></SaveDialog>
</template>
<script>
export default {
  name: "qa_parameter_testing",
};
</script>
<script setup>
import { onActivated, onDeactivated } from "vue";
// import { useRouter } from "vue-router";
import { ref, nextTick } from "vue";
import useScanner from "@/utils/scanner";
// , onMounted, reactive, ref
// const router = useRouter();
import SaveDialog from "./save";
import api from "@/api";
const dialog = ref({
  save: false,
});

const xGrid = ref({});
const saveDialog = ref({});
const handleSuccess = () => {
  xGrid.value.refresh();
};
const edit = function (data) {
  dialog.value.save = true;
  nextTick(() => {
    saveDialog.value.setData(data);
    saveDialog.value.open();
  });
};
const gridEvents = {
  cellDblclick: function ({ row }) {
    edit(row);
  },
  edit: function ({ button }) {
    edit(button.selectRecords[0]);
  },
};
const { close, open } = useScanner(val => {
  dialog.value.save = false;
  dialog.value.save = true;
  nextTick(() => {
    saveDialog.value.setCode(val);
    saveDialog.value.open();
  });
});
onActivated(() => {
  open();
});
onDeactivated(() => {
  close();
});
</script>
